package com.mebius.sys.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mebius.common.web.controller.BaseController;
import com.mebius.common.web.model.DataTable;
import com.mebius.common.web.validate.AjaxResponse;
import com.mebius.sys.service.UserService;
import com.mebius.sys.web.dto.UserDto;

@Controller
@RequestMapping("/admin/sys/user")
public class UserController extends BaseController {
	
	@Autowired
	private UserService userService ;

	@RequestMapping(value="/main", method=RequestMethod.GET)
	public String main() {
		return viewName("main") ;
	}
	
	@RequestMapping(value="/user_form", method=RequestMethod.GET)
	public String add_form_page(UserDto dto, Model model) {
		return viewName("user_form") ;
	}
	
	@RequestMapping(value="/add", method=RequestMethod.POST)
	@ResponseBody
	public AjaxResponse add(UserDto dto) {
		this.userService.add(dto) ;
		return new AjaxResponse() ;
	}
	
	@RequestMapping(value="/datagrid")
	@ResponseBody
	public DataTable datagrid(UserDto dto, Model model) {
		return this.userService.datagrid(dto) ;
	}
	
}
